package yxy.game.pm2.bean;

import org.redisson.api.RBucket;

import yxy.apple.util.redisson.RedisConnection;
import yxy.apple.util.redisson.RedisException;
import yxy.cherry.game.base.redis.RedisManager;
import yxy.cherry.game.base.redis.RedisType;

public class OrderUrl {

	public static final String orderurlkey = "orderurl";

	private static <V> RBucket<V> touch(RedisConnection redis, String key) throws RedisException {
		if (redis.ready()) {
			try {
				return redis.client().getBucket(key);
			} catch (Exception e) {
				throw new RedisException(e);
			}
		} else {
			throw new RedisException("无可用Redis连接!");
		}
	}
	
	public static void createorderurl(String url) throws RedisException {
		RBucket<String> bucket = touch(redis(), orderurlkey);
		bucket.set(url);
	}

	public static String orderurl() throws RedisException {
		RBucket<String> bucket = touch(redis(), orderurlkey);
		return bucket.get();
	}

	static private RedisConnection redis() {
		return RedisManager.getInstance().getConnection(RedisType.REDIS_GAME);
	}
	
}
